package com.mall.service.impl;

import com.mall.common.utils.Security;
import com.mall.controller.vo.CommentVO;
import com.mall.dao.custom.CtCommentMapper;
import com.mall.entity.Comment;
import com.mall.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author xyl
 * @date 2021-03-06 13:41
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CtCommentMapper commentMapper;

    @Override
    public int add(Comment comment) {
        comment.setCreateTime(new Date());
        comment.setCreateBy(Security.getCurrentUserId());
        return commentMapper.insert(comment);
    }

    @Override
    public List<CommentVO> listByGoodsId(Integer goodsId) {
        return commentMapper.selectVOByGoodsId();
    }
}
